home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Utils / Forecastfox / Bin / forecastfox-0.8.5.1-fx+mz+ns.xpi / components / ffResolver.js < prev    next >
Encoding:
Text File  |  2006-02-18  |  4.9 KB  |  140 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3.  *
  4.  * The contents of this file are subject to the Mozilla Public License Version
  5.  * 1.1 (the "License"); you may not use this file except in compliance with
  6.  * the License. You may obtain a copy of the License at
  7.  * http://www.mozilla.org/MPL/
  8.  *
  9.  * Software distributed under the License is distributed on an "AS IS" basis,
  10.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11.  * for the specific language governing rights and limitations under the
  12.  * License.
  13.  *
  14.  * The Original Code is Forecastfox.
  15.  *
  16.  * The Initial Developer of the Original Code is
  17.  * Jon Stritar <jstritar@MIT.EDU>.
  18.  * Portions created by the Initial Developer are Copyright (C) 2005
  19.  * the Initial Developer. All Rights Reserved.
  20.  *
  21.  * Contributor(s):
  22.  * Jon Stritar <jstritar@MIT.EDU>
  23.  * Richard Klein <richwklein@mchsi.com>
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  27.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38.  
  39. /* XPCOM Constants */
  40. const CLASS_ID = Components.ID("{3BEB2141-06DC-448c-BB1F-6EBE08A3764C}");
  41. const CLASS_NAME = "Forecastfox Namespace Resolver Component";
  42. const CONTRACT_ID = "@ensolis.com/forecastfox/resolver;1";
  43.  
  44. /******************************************************************************
  45.  * ffResolver Component
  46.  ******************************************************************************/
  47. function ffResolver()
  48. {  
  49.   //add our prefixes
  50.   this._prefixes = new Object();
  51.   this._prefixes["adc"] = "http://www.accuweather.com";
  52. };
  53.  
  54. ffResolver.prototype = {
  55.   _prefixes: null,
  56.   
  57.   lookupNamespaceURI: function(aPrefix)
  58.   {
  59.     if (aPrefix in this._prefixes)
  60.       return this._prefixes[aPrefix];
  61.     else
  62.       return null;
  63.   },
  64.      
  65.   ///////////////////////////
  66.   // nsIClassInfo  
  67.   getInterfaces: function(aCount)
  68.   {
  69.     var ifaces = new Array();
  70.     ifaces.push(Components.interfaces.nsIDOMXPathNSResolver);
  71.     ifaces.push(Components.interfaces.nsIClassInfo);
  72.     ifaces.push(Components.interfaces.nsISupports);
  73.     aCount.value = ifaces.length;
  74.     return ifaces;
  75.   },
  76.   
  77.   getHelperForLanguage: function(aLanguage) { return null; },
  78.   get contractID() { return CONTRACT_ID; },
  79.   get classID() { return CLASS_ID; },
  80.   get classDescription() { return CLASS_NAME; },
  81.   get implementationLanguage() { return Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT; },
  82.   get flags() { return Components.interfaces.nsIClassInfo.THREADSAFE; },
  83.          
  84.   ///////////////////////////
  85.   // nsISupports
  86.   QueryInterface: function (aIID)
  87.   {
  88.     if (!aIID.equals(Components.interfaces.nsIDOMXPathNSResolver) &&
  89.         !aIID.equals(Components.interfaces.nsIClassInfo) &&      
  90.         !aIID.equals(Components.interfaces.nsISupports))
  91.       throw Components.results.NS_ERROR_NO_INTERFACE;
  92.     return this;
  93.   }
  94. };
  95.  
  96. /******************************************************************************
  97.  * XPCOM Functions for construction and registration
  98.  ******************************************************************************/
  99. var gModule = {
  100.   _firstTime: true,
  101.   registerSelf: function(aCompMgr, aFileSpec, aLocation, aType)
  102.   {
  103.     if (this._firstTime) {
  104.       this._firstTime = false;
  105.       throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
  106.     };
  107.     aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  108.     aCompMgr.registerFactoryLocation(CLASS_ID, CLASS_NAME, CONTRACT_ID, aFileSpec, aLocation, aType);
  109.   },
  110.  
  111.   unregisterSelf: function(aCompMgr, aLocation, aType)
  112.   {
  113.     aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  114.     aCompMgr.unregisterFactoryLocation(CLASS_ID, aLocation);        
  115.   },
  116.   
  117.   getClassObject: function(aCompMgr, aCID, aIID)
  118.   {
  119.     if (!aIID.equals(Components.interfaces.nsIFactory))
  120.       throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  121.  
  122.     if (aCID.equals(CLASS_ID))
  123.       return gFactory;
  124.  
  125.     throw Components.results.NS_ERROR_NO_INTERFACE;
  126.   },
  127.  
  128.   canUnload: function(aCompMgr) { return true; }
  129. };
  130.  
  131. var gFactory = {
  132.   createInstance: function (aOuter, aIID)
  133.   {
  134.     if (aOuter != null)
  135.       throw Components.results.NS_ERROR_NO_AGGREGATION;
  136.     return (new ffResolver()).QueryInterface(aIID);
  137.   }
  138. };
  139.  
  140. function NSGetModule(aCompMgr, aFileSpec) { return gModule; }